<!--
 * @Descripttion: 下拉框
 * @Author: zhoujj
 * @Date: 2021-07-05 15:50:48
 * @LastEditors: zhoujj
 * @LastEditTime: 2021-07-07 09:39:20
-->
<template>
  <div v-if="item">
    <el-form ref="form" :rules="rules" :model="form" label-width="120px">
      <el-form-item :label="item.title" prop="value">
        <el-select
          v-model="form.value"
          :placeholder="item.msg"
          size="mini"
          @change="getVal"
        >
          <el-option
            v-for="val in item.selectData"
            :key="val.value"
            :label="val.label"
            :value="val.value"
          >
            <span style="float: left">{{ val.label }}</span>
            <slot style="float: right;" name="selectContent"></slot>
          </el-option>
        </el-select>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  props: ["item", "number"],
  data() {
    return {
      form: {
        value: "",
      },
      rules: {
        value: [
          {
            required: this.item.must,
            message: this.item.msg,
            trigger: "change",
          },
        ],
      },
    };
  },
  methods: {
    getVal(val) {
      this.$emit("changeComponent", {
        number: this.number,
        type: this.item.type,
        value: this.form.value,
      });
    },
  },
  mounted() {
    this.form = {
      ...this.form,
      ...this.item,
    };
  },
};
</script>

<style></style>
